#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>

namespace DiversityGraph {
//    template<typename T>
//    void read_graph_text(const char *path, std::vector<std::vector<T>> &out_graph, int &out_enter_point) {
//        std::ifstream instream;
//        instream.open(path, std::ios::in);
//        if (!instream.is_open()) {//判断文件是否打开
//            std::cout << "Error opening file" << std::endl;
//        }
//        int n_vertex;
//        instream >> n_vertex >> out_enter_point;
//        out_graph.clear();
//        out_graph.resize(n_vertex);
//        std::string line;
//        getline(instream, line);
//        for (int i = 0; i < n_vertex; i++) {
//            getline(instream, line);
//            int line_size = line.size();
//            char *input = new char[line_size + 1];
//            strcpy(input, line.c_str());
//            char *token = std::strtok(input, " ");
//            int size = std::atoi(token);
//            out_graph[i].resize(size);
//            for (int j = 0; j < size; j++) {
//                token = std::strtok(NULL, " ");
//                if (std::is_same<int, T>::value) {
//                    int tmp_num = std::atoi(token);
//                    out_graph[i][j] = tmp_num;
//                } else if (std::is_same<double, T>::value) {
//                    double tmp_num = std::atof(token);
//                    out_graph[i][j] = tmp_num;
//                } else {
//                    std::cout << "not support data type" << std::endl;
//                    return;
//                }
//            }
//            delete[] input;
//        }
//        std::printf("read vector graph success\n");
//    }

    std::vector<std::vector<int>> read_graph(const char *filename) {
        std::ifstream instream;
        instream.open(filename, std::ios::in);
        if (!instream.is_open()) {//判断文件是否打开
            std::cout << "Error opening file" << std::endl;
        }
        int n_vertex, n_edge, flag;
        instream >> n_vertex >> n_edge >> flag;
        if (flag != 1) {
            std::cout << "error graph mode" << std::endl;
        }
        printf("%d %d %d\n", n_vertex, n_edge, flag);
        std::vector<std::vector<int>> graph(n_vertex);
//        int tmp;
//        instream >> tmp;
//        printf("%d\n", tmp);

        std::string line;
        getline(instream, line);
        for (int i = 0; i < n_vertex; i++) {
            getline(instream, line);
            int line_size = line.size();
            char *input = new char[line_size + 1];
            strcpy(input, line.c_str());
            char *token = std::strtok(input, " ");
            int size = std::atoi(token);
            out_graph[i].resize(size);

            while(token != NULL){
                outg
            }
            for (int j = 0; j < size; j++) {
                token = std::strtok(NULL, " ");
                if (std::is_same<int, T>::value) {
                    int tmp_num = std::atoi(token);
                    out_graph[i][j] = tmp_num;
                } else {
                    std::cout << "not support data type" << std::endl;
                    return;
                }
            }
            delete[] input;
        }

        return graph;
    }
}